#include <stdio.h>

#include <qstring.h>
#include <qlist.h>

int main(void)
{
	QList<QString> l;

	l.setAutoDelete(TRUE);
	l.append(new QString("aaa"));
	l.append(new QString("bbb"));
	l.append(new QString("ccc"));

	for (QString *sp = l.first(); sp != 0; sp = l.next())
		printf("String %s\n", (const char *)*sp);
	for (QString *sp = l.first(); sp != 0; sp = l.next())
		printf("String %s\n", (const char *)*sp);

	QList<int> l2;

	l2.setAutoDelete(TRUE);
	l2.append(new int(1));
	l2.append(new int(2));
	l2.append(new int(3));

	for (int *ip = l2.first(); ip != 0; ip = l2.next())
		printf("int %d\n", *ip);

	QList<QString> l3;

	l3.setAutoDelete(TRUE);
	QString *s1 = new QString("item 1");
	QString *s2 = new QString("item 2");
	QString *s3 = new QString("item 3");
	QString *s4 = new QString("item 4");
	l3.append(s1);
	l3.append(s2);
	l3.append(s3);
	l3.append(s4);

	printf("Full list:\n");
	for (QString *sp = l3.first(); sp != 0; sp = l3.next())
		printf("%s\n", (const char *)*sp);
	l3.remove(s1);
	printf("After deleting item 1:\n");
	for (QString *sp = l3.first(); sp != 0; sp = l3.next())
		printf("%s\n", (const char *)*sp);
	l3.remove(s3);
	printf("After deleting item 3:\n");
	for (QString *sp = l3.first(); sp != 0; sp = l3.next())
		printf("%s\n", (const char *)*sp);
	l3.remove(s4);
	printf("After deleting item 4:\n");
	for (QString *sp = l3.first(); sp != 0; sp = l3.next())
		printf("%s\n", (const char *)*sp);
	l3.remove(s2);
	printf("After deleting item 2:\n");
	for (QString *sp = l3.first(); sp != 0; sp = l3.next())
		printf("%s\n", (const char *)*sp);

	return 0;
}
